<template>
  <!-- 字典分组 首页 -->
  <el-dialog
    v-el-drag-dialog
    :title="crud.status.title"
    :visible.sync="crud.status.info > 0"
    :before-close="crud.closeInfo"
  >
    <div class="info_detail_dialog__body">
      <el-card class="box-card" shadow="hover">
        <el-row :gutter="20">
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">详情ID: </div><div class="info_detail_value">{{ info.id }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">分组名称: </div><div class="info_detail_value">{{ info.name || '-' }}</div></el-col>
          <!-- 上级信息 -->
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">上级名称: </div><div class="info_detail_value">{{ info.parentName || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">下级数量: </div><div class="info_detail_value">{{ info.subCount || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">排序: </div><div class="info_detail_value">{{ info.paixu || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">描述: </div><div class="info_detail_value">{{ info.description || '-' }}</div></el-col>
          <!-- 状态值，字典取值 -->
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">状态 </div><div class="info_detail_value">{{ dict.label.common_status[info.status] || '未知字典码:'+info.status }}</div></el-col>

          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">创建时间:</div><div class="info_detail_value">{{ info.createTime || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">创建人:</div><div class="info_detail_value">{{ info.createUserName || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">最后一次修改时间:</div><div class="info_detail_value">{{ info.updateTime || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">最后一次修改人:</div><div class="info_detail_value">{{ info.updateUserName || '-' }}</div></el-col>

        </el-row>

      </el-card>
    </div>
  </el-dialog>
</template>

<script>
import elDragDialog from '@/directive/el-drag-dialog'
import CRUD, { info } from '@crud/crud'
// 字典分组 - model
const defaultInfo = {
  id: null, // id
  name: null, // 分组名称
  parentId: '0',
  _parentInfo: {}, // 父类信息
  parentName: null, // 父级名称
  subCount: null, // 下级数量
  paixu: 1,
  description: null, // 描述
  status: 1,
  lockVersion: 0,
  createTime: null,
  createUserName: null,
  updateTime: null,
  updateUserName: null,
  // _parentInfo: {},
  isDel: 0

}
export default {
  directives: { elDragDialog },
  mixins: [info(defaultInfo)],
  dicts: [
    'common_status'
  ], // 字典
  data() {
    return {

    }
  },
  mounted() {
  },
  methods: {
    [CRUD.HOOK.afterDoInfo]() {
      if (this.info.parentId && this.info.parentId !== '0') {
        this.crud.crudMethod.info(this.info.parentId).then(res => {
          this.info._parentInfo = res.data
        }).catch((error) => {
          this.crud.notify('未找到上级信息', CRUD.NOTIFICATION_TYPE.ERROR)
          console.log(error)
        })
      }
      return true
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
